//
//  LinkedList_insert.swift
//  SwiftyDSA
//
//  Created by Archer on 2018/8/6.
//  Copyright © 2018年 Archer. All rights reserved.
//

import Foundation

extension LinkedList {
    public func insertAsFirst(_ val: Element) {
        _size += 1
        _header.insertAsSuccessor(val)
    }
    
    public func insertAsLast(_ val: Element) {
        _size += 1
        _trailer.insertAsPredecessor(val)
    }
    
    public func insertBefore(_ node: LinkedListNode<Element>, val: Element) {
        _size += 1
        node.insertAsPredecessor(val)
    }
    
    public func insertAfter(_ node: LinkedListNode<Element>, val: Element) {
        _size += 1
        node.insertAsSuccessor(val)
    }
}
